<%@ Page Language="VB" StylesheetTheme="default"  MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="QuestionManager.aspx.vb" Inherits="Modules_Questionnaires_QuestionManager" title="Question Manager Page" %>
<%@ Register Assembly="DotNetPM.Web.UI.WebControls" TagPrefix="cc" Namespace="DotNetPM.Web.UI.WebControls" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table id="Table1" cellpadding="2" cellspacing="2" width="100%">
        <tr>
            <td colspan="4">
                <strong><font size="2">
                    <table cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            <td>
                                <asp:Image ID="Image1" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/Images/qman.gif" />
                                <strong><font size="3">QUESTION MANAGER</font></strong></td>
                            <td align="right">
                                <cc:dynimagebutton id="iButInstrument" runat="server" imagealign="AbsMiddle" imageurl="~/Images/iman_0.gif"
                                    tooltip="Instrument Manager"></cc:dynimagebutton>
                                <cc:dynimagebutton id="iButQuestionnaire" runat="server" imagealign="AbsMiddle" imageurl="~/Images/qnman_0.gif"
                                    tooltip="Questionnaire Manager"></cc:dynimagebutton>
                            </td>
                        </tr>
                    </table>
                </font></strong></td>
            <td align="right" colspan="1">
                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="Default.aspx" ForeColor="Blue">Back</asp:HyperLink></td>
        </tr>
        <tr>
            <td colspan="5" valign="top">
                <hr size="1" width="100%" /></td>
        </tr>
        <tr>
            <td rowspan="2" valign="top" width="15">&nbsp;</td>
            <td valign="top">
                <table border=0 cellpadding="4" >
                    <tr>
                        <td width=100 align="right"> Filter by Category : </td>
                        <td width=120 >
                            <asp:DropDownList ID="ddlCategories" runat="server" AppendDataBoundItems="True" DataSourceID="CategoryODS" DataTextField="Name" DataValueField="ID">
                                <asp:ListItem Selected="True" Value="0">None</asp:ListItem>
                            </asp:DropDownList>&nbsp;
                        </td>
                        <td width=120>
                            <asp:ObjectDataSource ID="CategoryODS" runat="server" OldValuesParameterFormatString="original_{0}"
                                SelectMethod="GetCategories" TypeName="DotNetPM.Business.Questionnaire.CategoryODS">
                            </asp:ObjectDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">Question contains : </td>
                        <td ><asp:TextBox ID="txtStringToSearch" runat="server"></asp:TextBox></td>
                        <td>
                            <asp:Button ID="butSearch" runat="server" Text="Search" Width="60px" />&nbsp;
                            <asp:Button ID="butClear" runat="server" Text="Clear" Width="60px" />&nbsp;
                        </td>
                    </tr>
                </table></td>
            <td align="right" valign="bottom">
                <asp:LinkButton ID="lbutNew" runat="server" Font-Bold="True"><SPAN style="POSITION: relative; TOP: -4px; left:-4px">Add A New Question</SPAN><img src="../../Images/New.gif" style="border-width:0px;POSITION: relative;" /></asp:LinkButton></td>
            <td colspan="2" valign="top" />
        </tr>
        <tr>
            <td colspan="2" height="300" valign="top">
                <asp:GridView ID="gvQuestions" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="odsQuestions" AllowSorting="True" DataKeyNames="ID" Width="820px" PageSize="10">
                    <Columns>
                        <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" >
                            <ItemStyle Width="25px" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Category" SortExpression="CategoryID">
                            <ItemStyle Width="120px" />
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# GetCategory(Eval("CategoryID")) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="Question" HeaderText="Question" SortExpression="Question" />
                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:HiddenField ID="hfID" runat="server" Value=<%# Bind("ID") %> />
                                <cc:DynImageButton ID="ibPreview" runat="server" CausesValidation=false CommandName="PreviewQuestion" 
                                     CommandArgument='<%# Container.DataItemIndex %>' AlternateText="Preview" ImageUrl="~/Images/Preview_0.gif"/>
                                <cc:DynImageButton ID="ibEdit" runat="server" CausesValidation=false CommandName="EditQuestion" 
                                     CommandArgument='<%# Container.DataItemIndex %>' AlternateText="Edit" ImageUrl="~/Images/Edit_0.gif"/>
                                <cc:DynImageButton ID="ibDel" runat="server" CausesValidation=false CommandName="Delete" visible=<%# IsAllowedToDelete() %>
                                     CommandArgument='<%# Container.DataItemIndex %>' AlternateText="Delete" ImageUrl="~/Images/delete_0.gif"
                                     OnClientClick="return confirm('Do you really want to delete this question?');"/>
                            </ItemTemplate>
                            <ItemStyle Width="60px" HorizontalAlign=center />
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                         <table border="0" cellpadding="2" cellspacing="2"
                            style="BORDER-TOP-WIDTH:1px;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-COLOR:black;LEFT:0px;BORDER-BOTTOM-WIDTH:1px;
                            BORDER-BOTTOM-COLOR:black;MARGIN:-4px;WIDTH:820px;BORDER-TOP-COLOR: black;TOP:0px;BACKGROUND-COLOR:white;
                            BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-COLOR: black">
                            <tr style="font-weight: bold; color: mistyrose; background-color: #4a3c8c">
                                <th>ID</th>
                                <th>Category</th>
                                <th>Question</th>
                                <th>&nbsp;</th>
                            </tr>
                            <tr id="trEmptyMessage" runat="server" visible="true" style="color:Black;background-color:#EEEEEE;">
	                            <td colspan=4 align=center >
	                                <br /><strong>There is no question in the database.</strong><br /><br />
	                            </td>
                            </tr>
                        </table>
                    </EmptyDataTemplate>
                </asp:GridView>
                <asp:ObjectDataSource ID="odsQuestions" runat="server"
                    SelectMethod="GetQuestions" TypeName="DotNetPM.Business.Questionnaire.QuestionODS" DeleteMethod="DeleteQuestion" OldValuesParameterFormatString="original_{0}">
                    <DeleteParameters>
                        <asp:Parameter Name="original_ID" Type="Int32" />
                    </DeleteParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ddlCategories" Name="CategoryID" PropertyName="SelectedValue"
                            Type="Int32" />
                        <asp:ControlParameter ControlID="txtStringToSearch" Name="StringToSearch" PropertyName="Text"
                            Type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </td>
            <td colspan="2"  valign="top">
            </td>
        </tr>
    </table>
 </asp:Content>

